package com.smartscreen.baseinfomanage.controller;

import com.smartscreen.baseinfomanage.dto.CreateAcademicYearRequest;
import com.smartscreen.baseinfomanage.entity.AcademicYear;
import com.smartscreen.baseinfomanage.service.AcademicService;
import com.smartscreen.common.response.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/base")
public class AcademicController {

    @Autowired
    private AcademicService academicService;

    @GetMapping("/academic-years")
    public ApiResponse<List<AcademicYear>> getAllAcademicYears() {
        List<AcademicYear> academicYears = academicService.getAllAcademicYears();
        return ApiResponse.success(academicYears);
    }

    @PostMapping("/academic-years")
    public ApiResponse<Map<String, String>> createAcademicYear(@RequestBody CreateAcademicYearRequest request) {
        String yearId = academicService.createAcademicYear(request);
        return ApiResponse.created("创建成功", Map.of("yearId", yearId));
    }
}